package com.wd.live.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MediatorLiveData;

import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.FindLiveListBean;
import com.wd.live.bean.GaiConstellationBean;
import com.wd.live.bean.GaiNameBean;
import com.wd.live.bean.GaiSexBean;
import com.wd.live.model.HttpUtils;

import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * <p>项目名称:LookFor2.0</p>
 * <p>包名:com.wd.live.viewmodel</p>
 * <p>简述:</p>
 *
 * @author 孟令高
 * @date 2022/11/22
 */
public class GaiNameViewModel extends BaseViewModel {
    public GaiNameViewModel(@NonNull Application application) {
        super(application);
    }
    private MediatorLiveData<GaiNameBean> liveData=new MediatorLiveData<>();
    public  MediatorLiveData<GaiNameBean> gainamelist(Map<String,Object> map,String name){
        HttpUtils.getHttpUtils().getApi()
                .gaiName(map, name)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<GaiNameBean>() {
                    @Override
                    public void accept(GaiNameBean gaiNameBean) throws Exception {
                        liveData.postValue(gaiNameBean);
                    }
                });
        return liveData;
    }
    //修改用户性别
    private MediatorLiveData<GaiSexBean> sexliveData=new MediatorLiveData<>();
    public  MediatorLiveData<GaiSexBean> gaisexlist(Map<String,Object> map,int sex){
        HttpUtils.getHttpUtils().getApi()
                .gaiSex(map, sex)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<GaiSexBean>() {
                    @Override
                    public void accept(GaiSexBean gaiSexBean) throws Exception {
                        sexliveData.postValue(gaiSexBean);
                    }
                });
        return sexliveData;
    }
    //修改用户星座
    private MediatorLiveData<GaiConstellationBean> conliveData=new MediatorLiveData<>();
    public  MediatorLiveData<GaiConstellationBean> gaiconliveDatalist(Map<String,Object> map,int con){
        HttpUtils.getHttpUtils().getApi()
                .gaiConstellation(map, con)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
               .subscribe(new Consumer<GaiConstellationBean>() {
                   @Override
                   public void accept(GaiConstellationBean gaiConstellationBean) throws Exception {
                       conliveData.postValue(gaiConstellationBean);
                   }
               });
        return conliveData;
    }
}
